package top.sdaily.business.controller.message;

import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.sdaily.message.push.PushManager;
import top.sdaily.web.context.ReturnBody;
import top.sdaily.web.context.SessionUser;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * Created by soya on 2017/3/12.
 */
@RestController
@RequestMapping("message/push")
public class PushController {

    @Autowired
    PushManager pushManager;

    @PostMapping(value = "sign")
    public ReturnBody sign(HttpServletRequest request, @RequestBody HashMap body) throws APIConnectionException, APIRequestException {
        String registrationId = request.getParameter("registrationId");
        registrationId = body.get("registrationId").toString();
        pushManager.bindUser("13000000000",registrationId);
        return ReturnBody.success();
    }
}
